$excludeFolders = @(
    "C:\Windows",
    "C:\Users"
)

# 获取C盘根目录下的所有顶级文件夹，但不包括要排除的文件夹
$folders = Get-ChildItem -Path C:\ -Directory | Where-Object { $excludeFolders -notcontains $_.FullName }
# 初始化变量来存储最大文件夹的信息
$maxSize = 0
$largestFolder = ""

# 遍历每个文件夹，计算其大小并找到最大的那个
foreach ($folder in $folders) {
    $size = (Get-ChildItem -Path $folder.FullName -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum

    if ($size -gt $maxSize) {
        $maxSize = $size
        $largestFolder = $folder.FullName
    }
}

# 输出结果
if ($largestFolder) {
    Write-Host "最大的文件夹是: $largestFolder,大小为: $(("{0:N2}" -f ($maxSize / 1MB))) MB"
} else {
    Write-Host "没有找到符合条件的文件夹。"
}